﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace ComicsEditor
{
    public class BalloonSelectInstrument : Instrument
    {
        private Balloon selectedBalloon;

        public BalloonSelectInstrument()
        {
        }

        public override bool Activate(Point point, out Point offset)
        {
            offset = Point.Empty;
            foreach (Balloon balloon in pageInfo.Balloons)
                if (balloon.Contains(point))
                {
                    pageInfo.BalloonSelect(balloon);
                    selectedBalloon = balloon;
                    return true;
                }
            pageInfo.BalloonSelect(null);
            return false;
        }

        public override void Drag(Point newPoint, Point offset, Point deltaActivate, Point deltaMove)
        {
            if (selectedBalloon != null)
            {
                selectedBalloon.Translate(deltaMove.X, deltaMove.Y);
                Page.Changed = true;
            }
        }

        public override void Deactivate()
        {
            selectedBalloon = null;
        }
    }
}
